﻿using System;
using System.Reflection;
using log4net;
using log4net.Core;
using log4net.Repository.Hierarchy;

namespace AutoBuild.Core.Framework
{
    public class ConsoleLogger : IConsole
    {
        private static log4net.ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);


        public void EnableDebugMode()
        {
            var loggerImpl = logger.Logger as Logger;
            if ( loggerImpl != null)
           {
                loggerImpl.Level = Level.Debug;
            }
            else
            {
                logger.Info(
                    "Could not enable Debug mode. Got a different logger implementation then expected." +
                    "Did you change the log4net configuration?");
            }
        }


        public ILog Logger
        {
            set { logger = value; }
        }


        public void Debug(string message)
        {
            logger.Debug(message);
        }

        public void Info(string message)
        {
            logger.Info(message);
        }

        public void Error(string message)
        {
            logger.Error(message);
        }

        public void Error(string message, Exception exception)
        {
            logger.Error(message, exception);
        }
    }
}